package net.huashitong.interview.service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;
import net.huashitong.interview.dao.ReadStateDao;
import net.huashitong.interview.entity.NeedSolveProblem;
import net.huashitong.interview.entity.NeedSolveReadState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ReadStateService extends StringPKService<NeedSolveReadState> {

    @Autowired
    private ReadStateDao dao;
    @Autowired
    private SysTableService tableService;

    @Override
    protected BaseDao<NeedSolveReadState, String> getDao() {
        return dao;
    }

    @Override
    protected void beforeSave(NeedSolveReadState obj) {
        obj.setSysId(tableService.updateMaxSysId("t_gis_interviewReadState", null));
    }

    public boolean getReadState(String needSolveId,String userId){
        return dao.getReadState(needSolveId,userId);
    }

    public NeedSolveReadState getBySolveIdAndUserId(String needSolveId,String userId){
        return dao.getBySolveIdAndUserId(needSolveId,userId);
    }
}
